package com.cw.demo.proxy;

/**
 * 学生代理类
 *
 * @author chenw
 * @date 2021/1/3
 */
public class StudentProxy implements Person{

    private Student student;

    /**
     * 构造方法
     */
    public StudentProxy(Person person){
        if(person.getClass() == Student.class){
            student = (Student) person;
        }
    }
    /**
     * 老师说话
     *
     * @param word
     */
    @Override
    public void talk(String word) {
        //老师说点总结
        System.out.println("学生们表现非常好");
        //代理学生说话
        student.talk(word);
    }
}
